package com.kgc.mapper;

import com.kgc.bean.GoodsItem;
import com.kgc.bean.OrderInfo;
import com.kgc.bean.OrderItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.core.annotation.Order;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Select("select * from order_info where order_id = #{orderId}")
    OrderInfo queryOrderInfoByOrderId(String orderId);

    @Select("select * from order_info where user_id = #{userId} and order_status = #{orderStateCode}")
    List<OrderInfo> queryAllOrdersByOrderState(@Param("userId") Integer userId, @Param("orderStateCode") Integer orderStateCode);

    @Select("select * from order_info where user_id = #{userId}")
    List<OrderInfo> queryAllOrders(Integer userId);

    @Select("select goods_id,goods_name,goods_price,shop_id from goods_item where goods_id = #{goodsId}")
    List<GoodsItem>queryorderitem(String goodsId);

    @Insert("insert into order_item(order_id,goods_id,title,num,pre_price,total_price,pic_path) values(#{orderId},#{goodsId},#{title},#{num},#{prePrice},#{totalPrice},#{picPath})")
    Boolean saveOrderItem(OrderItem orderItem);

    @Insert("insert into order_info(order_id,order_payment,order_status,order_create_time,order_payment_time,user_id,order_payment_type,last_payment_price) values(#{orderId},#{orderPayment},#{orderStatus},#{orderCreateTime},#{orderPaymentTime},#{userId},#{orderPaymentType},#{lastPaymentPrice})")
    Boolean saveOrderInfo(OrderInfo orderInfo);



}
